import { post } from "@/http/request";

// 登录所需的参数
export type LoginRequest = {
  username: string;
  password: string;
};

// 刷新登录信息需要的参数
export type reLoginRequest = {
  accessToken: string;
};

// 登录后返回的响应信息
export type LoginResponse = {
  username: string;
  roles: Array<string>;
  accessToken: string;
  token: string;
  userInfo: {
    id: number;
    email?: string;
    nickname?: string;
    user_pic?: string;
    user_pick?: string;
  };
};

// 登录
export const userLogin = async (data?: LoginRequest) => {
  return post<LoginResponse>({}, "/login", data);
};

// 刷新获取用户信息
export const refreshUserInfo = async (data: reLoginRequest) => {
  return post<LoginResponse>({}, "/getUserInfo", data);
};
